<!DOCTYPE html>
<html lang="en">
    <head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="format-detection" content="telephone=no" />

  <title>
    05|基础篇--某个应用的CPU使用率居然达到100%，我该怎么办？ | 迪克猪的博客
  </title>

  
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
  <link rel="manifest" href="/manifest.json" />
  <meta name="theme-color" content="#ffffff" />

  
  <link
    rel="stylesheet"
    href="https://unpkg.com/modern-normalize@0.6.0/modern-normalize.css"
  />

  
  
  
  
  <link rel="stylesheet" href="https://zsy619.github.io/style.min.f7761d111b74dd5c07f0111decee92938c12abc42e0fd319e1a07483e248b54e.css" integrity="sha256-93YdERt03VwH8BEd7O6Sk4wSq8QuD9MZ4aB0g&#43;JItU4=" />

  
  
    
  
</head>

    <body>
        <header id="header">
  <div class="header_container">
    <h1 class="sitetitle">
      <a href="https://zsy619.github.io" title="迪克猪的博客">迪克猪的博客</a>
    </h1>
    <nav class="navbar">
      <ul>
        <li><a href="https://zsy619.github.io">Home</a></li>
        
          <li>
            <a href="/post/">
              
              <span>LINUX性能优化</span>
            </a>
          </li>
        
          <li>
            <a href="/csapp/">
              
              <span>深入理解计算机系统_第三版</span>
            </a>
          </li>
        
          <li>
            <a href="/golang/">
              
              <span>golang</span>
            </a>
          </li>
        
          <li>
            <a href="/docker/">
              
              <span>容器</span>
            </a>
          </li>
        
          <li>
            <a href="/flutter/">
              
              <span>Flutter</span>
            </a>
          </li>
        
          <li>
            <a href="/know/">
              
              <span>知识点</span>
            </a>
          </li>
        
          <li>
            <a href="/categories/">
              
              <span>目录</span>
            </a>
          </li>
        
          <li>
            <a href="/about/">
              
              <span>关于</span>
            </a>
          </li>
        
        <li class="hide-sm"><a href="https://zsy619.github.io/index.xml" type="application/rss+xml">RSS</a></li>
      </ul>
    </nav>
  </div>
</header>

        
<section id="main">
  <article class="post content">
    <h2 class="title">05|基础篇--某个应用的CPU使用率居然达到100%，我该怎么办？</h2>
    <div class="post_content">
      <h3 id="cpu使用率">cpu使用率</h3>
<ul>
<li>定义节拍率（内核中用HZ表示），触发时间中断，并使用全局变量Jiffies记录开机以来的节拍率</li>
<li>没发生一次时间中断，Jiffies就增加1</li>
<li>节拍率设置值100、250、1000等，查询/boot/config来查看</li>
</ul>
<p><img src="../../images/20200530-2130-02.png" alt=""></p>
<p>表示每秒触发250次中断</p>
<ul>
<li>节拍率是内核选项，用户空间程序不能直接访问</li>
<li>用户节拍率USER_HZ默认是100</li>
<li>/proc虚拟文件系统
<ul>
<li>系统内部状态</li>
<li>/proc/stat提供cpu和任务系统信息</li>
</ul>
</li>
</ul>
<p><img src="../../images/20200530-2137-56.png" alt=""></p>
<ul>
<li>CPU使用率：就是空闲时间外的其他时间占总cpu时间的百分比</li>
</ul>
<p><img src="../../images/20200530-2140-41.png" alt=""></p>
<p><img src="../../images/20200530-2142-30.png" alt=""></p>
<ul>
<li>每个进程的运行情况：/proc/[pid]/stat</li>
</ul>
<h3 id="如何查看cpu使用率">如何查看cpu使用率</h3>
<ul>
<li>top显示系统整体cpu与内存使用情况，以及各个进程资源使用情况</li>
<li>ps显示每个进程的使用情况</li>
</ul>
<p><img src="../../images/20200530-2147-30.png" alt=""></p>
<h3 id="cpu使用过高">cpu使用过高</h3>
<ul>
<li>使用perf分析cpu性能</li>
</ul>

    </div>
    <div class="info post_meta">
      <time datetime=2020-05-29T12:45:21&#43;0800 class="date">Friday, May 29, 2020</time>
      
        <ul class="tags">
        
          <li> <a href="https://zsy619.github.io/tags/linux%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96">linux性能优化</a> </li>
        
          <li> <a href="https://zsy619.github.io/tags/linux">linux</a> </li>
        
        </ul>
      
      
    </div>
    <div class="clearfix"></div>
  </article>
  
    <div class="other_posts">
      
      <a href="https://zsy619.github.io/post/04%E5%9F%BA%E7%A1%80%E7%AF%87%E7%BB%8F%E5%B8%B8%E8%AF%B4%E7%9A%84cpu%E4%B8%8A%E4%B8%8B%E6%96%87%E5%88%87%E6%8D%A2%E6%98%AF%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D/" class="prev">04|基础篇--经常说的CPU上下文切换是什么意思</a>
      
      
      <a href="https://zsy619.github.io/post/06%E6%A1%88%E4%BE%8B%E7%AF%87%E7%B3%BB%E7%BB%9F%E7%9A%84cpu%E4%BD%BF%E7%94%A8%E7%8E%87%E5%BE%88%E9%AB%98%E4%BD%86%E4%B8%BA%E5%95%A5%E5%8D%B4%E6%89%BE%E4%B8%8D%E5%88%B0%E9%AB%98cpu%E7%9A%84%E5%BA%94%E7%94%A8/" class="next">06|案例篇--系统的CPU使用率很高，但为啥却找不到高CPU的应用？</a>
      
    </div>
    <aside id="comments">
</aside>

  
</section>

        <a id="back_to_top" title="Go To Top" href="#">
  <span>
    <svg viewBox="0 0 24 24">
      <path fill="none" d="M0 0h24v24H0z"></path>
      <path d="M12 2L4.5 20.29l.71.71L12 18l6.79 3 .71-.71z"></path>
    </svg>
  </span>
</a>

        <footer id="footer">
  <p>
    <span>&copy; 2021 <a href="https://zsy619.github.io" title="迪克猪的博客">迪克猪的博客</a> </span>
    <span>Built with <a rel="nofollow" target="_blank" href="https://gohugo.io">Hugo</a></span>
    <span>Theme by <a rel="nofollow" target="_blank" href="https://github.com/wayjam/hugo-theme-mixedpaper">WayJam</a></span>
  </p>

  <script src="https://zsy619.github.io/js/main.min.8b182175f5874aeed0acc0979345c98d4bde22208ec4f36cc1d6e3102acb4b10.js" integrity="sha256-ixghdfWHSu7QrMCXk0XJjUveIiCOxPNswdbjECrLSxA=" crossorigin="anonymous" async></script>
</footer>

    </body>
</html>
